var prefix = "/cms/kind"

$(document).ready(function() {
  getTreeData()
});

function getTreeData() {
  $.ajax({
    type : "GET",
    url : prefix + "/tree",
    success : function(tree) {
      loadTree(tree);
    }
  });
}

function loadTree(tree) {
  $('#kindTree').jstree({
    'core' : {
      'data' : tree
    },
    "plugins" : [ "search" ]
  });
  $('#kindTree').jstree().open_all();
}

$('#kindTree').on("changed.jstree", function(e, data) {
  if(data.node.id != -1) {
    parent.loadKind(data.node.id,data.node.text);
    var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
    parent.layer.close(index);
  }
});
